using Brain;
using Brain.Dev;
using Brain.Rendering;
using Microsoft.Xna.Framework;
using System;
using System.IO;
using System.Threading;
using Microsoft.Xna.Framework.Graphics;
using Brain.Logic.AI;
using Brain.Bepu;
#if !MONOGAME
using Brain.Farseer;
#endif
using Brain.IO;

namespace Demos
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.IsFullScreen = false;

            this.IsMouseVisible = true;
        }

        protected override void Initialize()
        {
            base.Initialize();

            Engine.InitializeEngineWithDefaultManagers(this.graphics);
#if DEBUG
            Engine.Instance.AddManager(new DefaultDebugManager());
#endif
            Engine.Instance.AddManager(new DefaultRenderManager2D(this.GraphicsDevice));
            Engine.Instance.AddManager(new DefaultRenderManager3D(this.GraphicsDevice));

            Engine.Instance.AddManager(new DefaultStereoscopicManager());

            Engine.Instance.AddManager(new DefaultAIManager());
            Engine.Instance.AddManager(new BepuPhysicsManager());
#if !MONOGAME
            Engine.Instance.AddManager(new FarseerPhysicsManager2D());
#endif

            new MainMenuScreen();
        }

        protected override void UnloadContent()
        {
            base.UnloadContent();

            Engine.Instance.Unload();
        }

        protected override void Update(GameTime gameTime)
        {
            Engine.Instance.Update(gameTime);

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            Engine.Instance.Draw(gameTime);

            base.Draw(gameTime);
        }
    }
}
